asm
  ld sp,$7FFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"

dim eee as uinteger at $4010
dim seed as uinteger at $4012
dim ee0 as uinteger at $4014
dim ee1 as uinteger at $4016
dim ee2 as uinteger at $4018
dim ee3 as uinteger at $401A
dim eex as uinteger at $401C
dim eey as uinteger at $401E

seed=0


sub naughtyboyputcharf(txp1 as uinteger,typ1 as uinteger, tch1 as ubyte, tat1 as ubyte):
  if typ1>=2 and typ1<=33 then:
    poke ($8000+((txp1+4)*64)+(typ1-2)) bxor %11111000000,tch1
    poke ($8800+((txp1+4)*64)+(typ1-2)) bxor %11111000000,tat1
  else:
    poke ($8700+ ((typ1+2)mod 36) + ((txp1+4)*4) ) bxor %1111100,tch1
    poke ($8F00+ ((typ1+2)mod 36) + ((txp1+4)*4) ) bxor %1111100,tat1
    end if
  poke $50C0,255
  end sub



for ee0=0 to 35
  for ee1=0 to 27
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    'naughtyboyputcharf(ee1,ee0,seed band 3,0)
    naughtyboyputcharf(ee1,ee0,seed band 3,ee2 band %10)
    smsdelay(500)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    naughtyboyputcharf(ee1+11,ee0+19,ee0*16+ee1,0)
    smsdelay(500)
    next:next

eex=8:eey=8
eee=0
do

naughtyboyputcharf(1,1,48+(int(eee/100) mod 10),1)
naughtyboyputcharf(2,1,48+(int(eee/10) mod 10),1)
naughtyboyputcharf(3,1,48+(eee mod 10),1)

ee0=peek($B7FF) bxor $FF
naughtyboyputcharf(1,3,48+(int(ee0/100) mod 10),1)
naughtyboyputcharf(2,3,48+(int(ee0/10) mod 10),1)
naughtyboyputcharf(3,3,48+(ee0 mod 10),1)

eex=eex+((ee0 band 64)/64)-((ee0 band 128)/128)
eey=eey-((ee0 band 16)/16)+((ee0 band 32)/32)

ee0=peek($BFFF)
naughtyboyputcharf(1,4,48+(int(ee0/100) mod 10),1)
naughtyboyputcharf(2,4,48+(int(ee0/10) mod 10),1)
naughtyboyputcharf(3,4,48+(ee0 mod 10),1)



naughtyboyputcharf(eex,eey,eee mod 96,0)

smsdelay(5000)
eee=eee+1
loop



'static ADDRESS_MAP_START( naughtyb_map, AS_PROGRAM, 8, naughtyb_state )
'	AM_RANGE(0x0000, 0x3fff) AM_ROM
'	AM_RANGE(0x4000, 0x7fff) AM_RAM
'	AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("videoram")
'	AM_RANGE(0x8800, 0x8fff) AM_RAM AM_SHARE("videoram2")
'	AM_RANGE(0x9000, 0x97ff) AM_WRITE(naughtyb_videoreg_w)
'	AM_RANGE(0x9800, 0x9fff) AM_RAM AM_SHARE("scrollreg")
'	AM_RANGE(0xa000, 0xa7ff) AM_DEVWRITE("naughtyb_custom", naughtyb_sound_device, control_a_w)
'	AM_RANGE(0xa800, 0xafff) AM_DEVWRITE("naughtyb_custom", naughtyb_sound_device, control_b_w)
'	AM_RANGE(0xb000, 0xb7ff) AM_READ(in0_port_r)    // IN0
'	AM_RANGE(0xb800, 0xbfff) AM_READ(dsw0_port_r)   // DSW0
'ADDRESS_MAP_END

do:loop





































'-----------------------------------------------------

'- simplificar para um putchar
do

for ee0=$702 to $77F step 4
  ee2=seed:seed=smsrnd(seed)
  ee2=seed:seed=smsrnd(seed)
  poke $8000+(ee0 bxor 124),seed
  poke $8800+(ee0 bxor 124),seed
  smsdelay(2000)
  next

for ee0=$703 to $77F step 4
  ee2=seed:seed=smsrnd(seed)
  ee2=seed:seed=smsrnd(seed)
  poke $8000+(ee0 bxor 124),seed
  poke $8800+(ee0 bxor 124),seed
  smsdelay(2000)
  next

for ee0=0 to 31
  for ee1=4 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    poke $8000+(ee1 bxor 31)*64+ee0,seed
    poke $8800+(ee1 bxor 31)*64+ee0,seed
    smsdelay(2000)
    next:next

for ee0=$700 to $77F step 4
  ee2=seed:seed=smsrnd(seed)
  ee2=seed:seed=smsrnd(seed)
  poke $8000+(ee0 bxor 124),seed
  poke $8800+(ee0 bxor 124),seed
  smsdelay(2000)
  next

for ee0=$701 to $77F step 4
  ee2=seed:seed=smsrnd(seed)
  ee2=seed:seed=smsrnd(seed)
  poke $8000+(ee0 bxor 124),seed
  poke $8800+(ee0 bxor 124),seed
  smsdelay(2000)
  next

loop

do:loop
'--------------------------------------------------


do

for ee0=$700 to $77F step 4
  ee2=seed:seed=smsrnd(seed)
  ee2=seed:seed=smsrnd(seed)
  poke $8000+ee0,seed
  poke $8800+ee0,seed
  smsdelay(2000)
  next


for ee0=$000 to $7FF
  ee2=seed:seed=smsrnd(seed)
  ee2=seed:seed=smsrnd(seed)
  poke $8000+ee0,seed
  poke $8800+ee0,seed
  smsdelay(2000)
  next

loop



do

for ee0=0 to 31
  for ee1=28 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    poke $8000+ee1*64+ee0,seed
    poke $8800+ee1*64+ee0,seed
    smsdelay(8000)
    next:next



loop

do:loop



do:loop



